package com.minimalist.lindi.controller;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.priceconfig.LindiPriceConfigQueryVO;
import com.minimalist.common.entity.lindi.vo.priceconfig.LindiPriceConfigVO;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import com.minimalist.lindi.service.LindiPriceConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地指标交易平台_价格配置管理
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_价格配置管理")
@RequestMapping("/lindi/priceConfig")
public class LindiPriceConfigController {

    @Autowired
    private LindiPriceConfigService service;

    @PostMapping("/addPriceConfig")
    @Operation(summary = "添加价格配置")
    public R<?> addPriceConfig(@RequestBody @Validated(Add.class) LindiPriceConfigVO priceConfigVO) {
        service.addPriceConfig(priceConfigVO);
        return R.ok();
    }

    @DeleteMapping("/deletePriceConfigByPriceConfigId")
    @Operation(summary = "删除价格配置 -> 根据价格配置ID删除")
    public R<?> deletePriceConfigByPriceConfigId(
            @RequestParam("priceConfigId")
            @NotNull(message = "价格配置ID不能为空")
            @Parameter(name = "priceConfigId", required = true, description = "价格配置ID")
            Long priceConfigId) {
        service.deletePriceConfigByPriceConfigId(priceConfigId);
        return R.ok();
    }

    @PutMapping("/updatePriceConfigByPriceConfigId")
    @Operation(summary = "修改价格配置")
    public R<?> updatePriceConfigByPriceConfigId(
            @RequestBody @Validated(Update.class) LindiPriceConfigVO priceConfigVO) {
        service.updatePriceConfigByPriceConfigId(priceConfigVO);
        return R.ok();
    }

    @GetMapping("/getPagePriceConfigList")
    @Operation(summary = "查询价格配置列表(分页)")
    public R<PageResp<LindiPriceConfigVO>> getPagePriceConfigList(@RequestBody LindiPriceConfigQueryVO queryVO) {
        return R.ok(service.getPagePriceConfigList(queryVO));
    }

    @GetMapping("/getPriceConfigByPriceConfigId/{priceConfigId}")
    @Operation(summary = "根据价格配置ID查询价格配置")
    public R<LindiPriceConfigVO> getPriceConfigByPriceConfigId(
            @PathVariable(value = "priceConfigId")
            @NotNull(message = "价格配置ID不能为空")
            @Parameter(name = "priceConfigId", description = "价格配置ID", required = true)
            Long priceConfigId) {
        return R.ok(service.getPriceConfigByPriceConfigId(priceConfigId));
    }

}